
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="guide">
	<tr>
		<td>
			<span style="float: left;">后台管理中心&nbsp;&raquo;&nbsp;权限管理</span>
			<span style="float: right;">
				<a href="./?controller=aclResource&action=add">+ 添加权限对象</a>
				<a href="javascript:history.go(-1);">&lt;- 返回</a>
			</span>
		</td>
	</tr>
</table>

<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tableborder">
	<tr class="header">
		<td colspan="11">权限列表</td>
	</tr>
	<tr class="category" align="center">
		<td width="16%">群组</td>
		<td width="42%">已分配权限</td>
		<td width="42%">未分配权限</td>
	</tr>
<?php
$resourceArray = array();

foreach ($this->aclResourceData as $aclResourceRow)
	$resourceArray[$aclResourceRow['id']] = $aclResourceRow['description'];

$i = 0;

foreach ($this->groupData as $groupRow)
{
	$groupid			= $groupRow['id'];
	$groupname			= $groupRow['name'];
	$aclData			= $this->acl->getTable()->listAll(array('groupid' => $groupid));
	$allocated			= array();
	$allocatedString	= '';
	$unallocatedString	= '';
	
	foreach ($aclData as $aclRow)
	{
		$aclid		= $aclRow['id'];
		$resourceid	= $aclRow['resourceid'];
		$allocated[]= $resourceid;
		
		$allocatedString .= $resourceArray[$resourceid].' <a href="./?controller=acl&action=delete&id='.$aclid.'">删除</a><br />';
	}
	
	foreach ($resourceArray as $resourceid => $description)
	{
		if (array_search($resourceid, $allocated) === false)
			$unallocatedString .= $description.' <a href="./?controller=acl&action=add&groupid='.$groupid.'&resourceid='.$resourceid.'">添加</a><br />';
	}
	
	echo <<<EOF
	<tr align="center">
		<td class="altbg1"><a href="./?controller=group&id=$groupid">$groupname</a></td>
		<td class="altbg2">$allocatedString</td>
		<td class="altbg1">$unallocatedString</td>
	</tr>
EOF;
}
?>
</table>
